package com.cpecc.liucheng.dao;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.cpecc.liucheng.model.HuanJie;

@Repository
public class HuanJieDao {

	@Resource
	private SessionFactory sessionFactory;
	
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	
	public HuanJie get(int id){
		return (HuanJie) sessionFactory.getCurrentSession().get(HuanJie.class, id);
	}
	
	public HuanJie get1(int id){
		HuanJie huanJie=new HuanJie();
		Session session=sessionFactory.openSession();
		HuanJie temp=(HuanJie) session.get(HuanJie.class, id);
		if(temp!=null){
			huanJie.setId(temp.getId());
		}
		session.close();
		return huanJie;
	}
}
